package cn.woniu.ecommerceplatform.controller;

import cn.woniu.ecommerceplatform.entity.Type;
import cn.woniu.ecommerceplatform.service.TypeService;
import cn.woniu.ecommerceplatform.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/type")
public class TypeController {
    @Autowired
    private TypeService typeService;
    @RequestMapping("queryList")
    public ResponseResult<?> queryType(String typeName,String typeKey,Integer pageNum,Integer pageSize){
        return typeService.queryList(typeName,typeKey,pageNum,pageSize);
    }
    @PostMapping("insert")
    public ResponseResult<?> insertType(@RequestBody Type type){
        return typeService.insertType(type);
    }
    @RequestMapping("delete")
    public ResponseResult<?> deleteById(Integer id){
        return typeService.delTypeById(id);
    }
    @PostMapping("deleteList")
    public ResponseResult<?> deleteList(@RequestBody Integer[] ids){
        return typeService.deleteTypes(ids);
    }
    @PostMapping("update")
    public ResponseResult<?> updateType(@RequestBody Type type){
        return typeService.updateTypeById(type);
    }
}
